//
//  HPYEmoticonKeyboardView.swift
//  SwiftVVBo
//
//  Created by hepeiyong on 16/8/18.
//  Copyright © 2016年 hpyhn. All rights reserved.
//

import UIKit

@available(iOS 9.0, *)
class HPYEmoticonKeyboardView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - 设置视图
    private func setupUI(){
        backgroundColor = UIColor(patternImage: UIImage(named: "emoticon_keyboard_background")!)
        // 添加控件
        addSubview(emoticonBottomView)
        addSubview(emoticonPageView)
        // 添加约束
        emoticonBottomView.snp_makeConstraints { (make) -> Void in
            make.leading.bottom.trailing.equalTo(self)
            make.height.equalTo(37)
        }

        emoticonPageView.snp_makeConstraints { (make) -> Void in
            make.leading.top.trailing.equalTo(self)
            make.bottom.equalTo(emoticonBottomView.snp_top)
        }


        // 底部视图闭包回调
        emoticonBottomView.closure = {(type: HPYEmoticonBottomViewType)->() in

            switch type {
            case .Default :
                print("默认")
            case .Emoji :
                print("Emoji")
            case .Lxh :
                print("浪小花")
            }

        }

    }

    // MARK: - 懒加载控件
    // 底部视图
    private lazy var emoticonBottomView: HPYEmoticonBottomView = HPYEmoticonBottomView(frame: CGRectZero)
    // 指定表情键盘视图
    private lazy var emoticonPageView: HPYEmoticonPageView = {
        let view = HPYEmoticonPageView()
        // 分页
        view.pagingEnabled = true
        // 取消弹簧效果
        view.bounces = false
        // 隐藏滚动条
        view.showsHorizontalScrollIndicator = false
        view.showsVerticalScrollIndicator = false
        return view
    }()
    
}

